<?php
    $this->headTitle(@$this->enterprise->company_name_vn.': '.$this->translator('b2b_gallery_list'));
?>
<style>
    .b_a_right{
        text-align: right;
        padding-bottom:5px;
    }
    .g_content{

    }
    .col_20{
        float: left;
        width: 20%;
    }
    .g_content{
        padding : 10px 0 0 0;
    }
    .g_content .g_image{
        text-align: center;
    }
    .g_content .subcolumns{
        padding: 0 0 10px 0;
    }
    .b_a_paginator{
        text-align: center;
    }
</style>

<div class="grid_12">
    <div class="grid_8 alpha">
        <?php if(!$this->found):?>
        <?php echo $this->translator('not_found_database');?>
        <?php else:?>
        <!--Sub menu-->
        <?php echo $this->widget('bizprofile','menu',array()); ?>
        <!--End sub menu-->
        <div class="subcolumns"">
            <?php if($this->allow('add') && $this->allowAction):?>
        	<div class="b_a_right">
                <?php
                    $arrRouteAdd = array(
                        'enterprise_id' => $this->enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
                    );
                ?>
                <a href="<?php echo $this->url($arrRouteAdd, 'b2b_gallery_add');?>"><?php echo $this->translator('gallery_add_btn');?></a>
                &nbsp; 
            </div>
            <?php endif;?>
            <?php if(!count($this->sets) > 0):?>
            <div class="g_content" style="text-align:center;">
                <?php echo $this->translator('gallery_list_not_found');?>
            </div>
            <?php else:?>
            <div class="g_content">
                <?php  if(!$this->permission || $this->permission->media_permission  == 1  || $this->permission_viewall == 1){?> <!-- Được quyền xem Album -->
            	
            	<?php $i = 0; foreach($this->sets as $set):?>
                    <?php
                        /**
                        * Check exist image
                        **/
                        $file    = $set->image_thumbnail;
                        $path    = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
                        $image = (is_file($path)) ? $file:$this->baseUrl() . "/skins/bizprofile/default/html/images/vittel.jpg";
                    ?>
                    <?php if($i%5==0):?>
                <div class="subcolumns">
                    <?php endif;?>
                    <div class="col_20 g_image">
                        <?php
                            $arrRouteAlbum = array(
                                'enterprise_id' => $this->enterprise->id,
                                'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
                                'slug' => $set->slug,
                                'set_id' => $set->set_id
                            );
                        ?>
                        <a href="<?php echo $this->url($arrRouteAlbum, 'b2b_gallery_album');?>"><img width="120" src="<?php echo $image;?>" /></a>
                        <a href="<?php echo $this->url($arrRouteAlbum, 'b2b_gallery_album');?>"><?php echo $set->title;?></a>
                        <br />
                        <b><?php echo $set->num_image;?> <?php echo $this->translator('gallery_image_guide');?></b>
                    </div>
                    <?php $i++; if($i%5 == 0):?>
                </div>
                    <?php endif;?>
                <?php endforeach;?>
                    <?php if($i%5 != 0):?>
                </div>
                    <?php endif;?>
                <?php   }else{?>   <!-- Không được quyền xem Album -->
                	<?php  echo $this->translator("permisson_gallery_allow_view_album"); ?>
                <?php  }?>    
            </div>
            <div class="b_a_paginator">
                <?php echo $this->paginator()->slide($this->paginator, $this->paginatorOptions);?>
            </div>
            <?php endif;?>
        </div>
        <?php endif;?>
    </div>
    <div class="grid_4 omega">
        <?php echo $this->widget('bizprofile','map',array()); ?>
        <?php echo $this->widget('bizprofile','help',array()); ?>
    </div>
</div>
<div class="grid_12">
    <?php echo $this->widget('bizprofile','contact',array()); ?>
</div>